package danran.rpc.common.util;

import danran.rpc.common.service.CacheItem;
import danran.rpc.common.service.Service;

import java.util.List;

/**
 * @Classname CacheItemUtil
 * @Description TODO
 * @Date 2021/9/27 16:50
 * @Created by ASUS
 */
public class CacheItemUtil {
    /**
     * 判断服务缓存Item是否发生变化
     */
    public static boolean isSame(CacheItem a, CacheItem b) {
        if (a == null || b == null) return false;
        if (a.size() != b.size()) return false;
        List<Service> aL = a.getServiceList();
        List<Service> bL = b.getServiceList();
        for (int i = 0; i < a.size(); i++) {
            if (!ServiceUtil.isSame(aL.get(i), bL.get(i))) return false;
        }
        return true;
    }
}
